package org.hzero.order.api.controller.v1;

import java.util.List;

import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.hzero.core.util.Results;
import org.hzero.export.annotation.ExcelExport;
import org.hzero.export.vo.ExportParam;
import org.hzero.order.config.SwaggerTags;
import org.hzero.order.domain.entity.dto.OrderDTO;
import org.hzero.order.domain.repository.OrderRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import io.choerodon.core.iam.ResourceLevel;
import io.choerodon.mybatis.pagehelper.domain.PageRequest;
import io.choerodon.swagger.annotation.Permission;

/**
 * @author xiuiqng.Yang-Estelle-양수청
 * @date 2019/8/6 20:13
 */

@Api(tags = SwaggerTags.EXPORT)
@RestController("exportController.v1")
@RequestMapping("/v1/{organizationId}/export/data")
public class ExportController {

    @Autowired
    private OrderRepository orderRepository;

    @ApiOperation(value = "导出订单详情")
    @Permission(level = ResourceLevel.SITE, permissionLogin = true)
    @GetMapping
    @ExcelExport(OrderDTO.class)
    public ResponseEntity export(ExportParam exportParam, HttpServletResponse response, PageRequest pageRequest) {
        return Results.success(orderRepository.export(pageRequest));
    }

}
